import { defineStore } from "pinia";
import { ref } from "vue";

// 定义用户状态仓库
export const useUserStore = defineStore(
  "backPath",
  () => {
    //  记录回跳地址，修改回跳地址
    const returnUrl = ref("/pages/index/index");
    const updateReturnUrl = (url) => (returnUrl.value = `/pages/${url}/index`);

    const firstRoute = ref("");
    const isRefresh = ref(false);

    const updatefirstRoute = (url) => (firstRoute.value = url);
    const updateIsRefresh = (value) => (isRefresh.value = value);
    return { returnUrl, firstRoute, updateReturnUrl, updatefirstRoute,updateIsRefresh,isRefresh };
  },
  {
    // 开启持久化（使用本地存储，默认是localStorage）
    persist: true,
  }
);
